package com.example.smartcity_40.Outpatient;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.example.smartcity_40.Outpatient.apter.OutpatienttypeApter;
import com.example.smartcity_40.Outpatient.bean.OutpatienttypeBean;
import com.example.smartcity_40.R;
import com.example.smartcity_40.tool.Tool;
import com.google.android.material.tabs.TabLayout;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;

public class OutpatientTypeActivity extends AppCompatActivity {

    private OutpatientTypeActivity context;
    private Tool tool;
    private RecyclerView registerlist;
    private OutpatienttypeApter outpatienttypeApter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_go_to_department);
        context = this;
        initview();
        outpatienttypemethod();
    }

    private void outpatienttypemethod() {
        tool.send("/prod-api/api/hospital/category/list",
                Tool.GET,
                null,
                true,
                OutpatienttypeBean.class,
                new Function1<OutpatienttypeBean, Unit>() {
                    @Override
                    public Unit invoke(OutpatienttypeBean outpatienttypeBean) {
                        registerlist.setLayoutManager(new LinearLayoutManager(context));
                        outpatienttypeApter.setDate(outpatienttypeBean.getRows());
                        registerlist.setAdapter(outpatienttypeApter);
                        return null;
                    }
                });
    }

    private void initview() {
        ImageView back = findViewById(R.id.back);
        registerlist = findViewById(R.id.registerlist);
        tool = new Tool(context);
        outpatienttypeApter = new OutpatienttypeApter(context);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.finish();
            }
        });
    }
}